package io.renren.modules.app.controller;


import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.app.entity.AppCloumn;
import io.renren.modules.app.service.AppCloumnService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

/**
 * 应用栏目表
 *
 * @author chenjiacheng
 * @email 
 * @date 2019-02-11 19:04:20
 */
@RestController
@RequestMapping("app/appcloumn")
public class AppCloumnController {
    @Autowired
    private AppCloumnService appCloumnService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("app:appcloumn:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = appCloumnService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{columnId}")
    @RequiresPermissions("app:appcloumn:info")
    public R info(@PathVariable("columnId") Integer columnId){
			AppCloumn appCloumn = appCloumnService.selectById(columnId);

        return R.ok().put("appCloumn", appCloumn);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("app:appcloumn:save")
    public R save(@RequestBody AppCloumn appCloumn){
			appCloumnService.insert(appCloumn);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("app:appcloumn:update")
    public R update(@RequestBody AppCloumn appCloumn){
			appCloumnService.updateById(appCloumn);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("app:appcloumn:delete")
    public R delete(@RequestBody Integer[] columnIds){
			appCloumnService.deleteBatchIds(Arrays.asList(columnIds));

        return R.ok();
    }

}
